package org.dromara.oce.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.oce.domain.OceAdvertiserReferralRelation;
import org.dromara.oce.domain.vo.OceAdvertiserReferralRelationVo;

import java.util.List;

/**
 * 推广链接-广告主关联Mapper接口
 *
 * @author Lion Li
 * @date 2024-12-24
 */
public interface OceAdvertiserReferralRelationMapper extends BaseMapperPlus<OceAdvertiserReferralRelation, OceAdvertiserReferralRelationVo> {
    /**
     * 根据推广链接id，查询绑定广告主信息
     * @param referralLinkId
     * @return
     */
    @Select("select * from oce_advertiser_referral_relation where referral_link_id = #{referralLinkId} order by advertiser_referral_id desc limit 1")
    public OceAdvertiserReferralRelation getAdvertiserInfoByReferralLinkId(@Param("referralLinkId") Long referralLinkId);

    @Override
    @DataPermission({
        @DataColumn(key = "deptName", value = "dept_id")
    })
    List<OceAdvertiserReferralRelation> selectList(IPage<OceAdvertiserReferralRelation> page, @Param(Constants.WRAPPER) Wrapper<OceAdvertiserReferralRelation> queryWrapper);

    @Override
    @DataPermission({
        @DataColumn(key = "deptName", value = "dept_id")
    })
    List<OceAdvertiserReferralRelation> selectList(@Param(Constants.WRAPPER) Wrapper<OceAdvertiserReferralRelation> queryWrapper);

    List<OceAdvertiserReferralRelation> selectJobList(@Param(Constants.WRAPPER) Wrapper<OceAdvertiserReferralRelation> queryWrapper);

    /**
     * 查询绑定的所有推广链接
     * @return
     */
    List<Long> getReferralLinkIdList(@Param("referralLinkType") Integer referralLinkType);
    List<Long> getAllReferralLinkIdList(@Param("referralLinkType") Integer referralLinkType);

}
